//
//  qiyeViewController.m
//  hainingOASystem
//
//  Created by michael on 2017/12/14.
//  Copyright © 2017年 czd. All rights reserved.
//
#import <CommonCrypto/CommonDigest.h>

#import "qiyeViewController.h"
#import "OALoginViewController.h"
@interface qiyeViewController ()

@end
static int countDownTime = 180;

@implementation qiyeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
             self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.title = @"企业注册";
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth,KScreenHeight-kTopHeight) style:UITableViewStylePlain];
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

_tableView.dataSource = self;
_tableView.delegate = self;
[self.view addSubview:_tableView];
[self requestdata];
    // Do any additional setup after loading the view.
}
- (void)requestdata{
[httpTool ZBPostNetDataWith:kqiyelist withDic:nil andSuccess:^(NSDictionary* dictionary){
    
    _cityarray = dictionary[@"cityList"];
    _hyarray = dictionary[@"professionsList"];
      _jgarray = dictionary[@"qualityList"];
    NSMutableArray *array1 = [NSMutableArray array];
    for (NSDictionary *dic in _cityarray) {
    [array1 addObject: dic[@"name"]];
}
    _huji1array = array1;
    
     NSMutableArray *array2 = [NSMutableArray array];
    for (NSDictionary *dic in _hyarray) {
    [array2 addObject: dic[@"name"]];
}
    _hyNSarray = array2;
    
   NSMutableArray *array3 = [NSMutableArray array];
    for (NSDictionary *dic in _jgarray) {
    [array3 addObject: dic[@"name"]];
}
    _jgNSarray = array3;
    
    
    
    
    [_tableView reloadData];
       }andFailure:^{

        [self.view makeToast:@"网络错误!"];

 }];

}
-(void)endediting
{
NSString *oldstring=[_yhmField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([oldstring isEqualToString:@""]|| oldstring.length == 0|| oldstring.length!=18) {
_yhmField.layer.borderColor = [[UIColor redColor] CGColor];
     [self.view makeToast:@"用户名不规范!"];
}else{
  NSString *url = [NSString stringWithFormat:@"%@%@",kqiyename,oldstring];
       [httpTool ZBPostNetDataWith:url withDic:nil andSuccess:^(NSDictionary* dictionary){
       if ([[NSString stringWithFormat:@"%@",dictionary[@"success"]]isEqualToString:@"true"]) {
           [self .view makeToast:dictionary[@"msg"]];
           _nametype = @"yes";
 _yhmField.layer.borderColor=[[UIColor grayColor]CGColor];
[_tableView reloadData];
}else{
_yhmField.layer.borderColor = [[UIColor redColor] CGColor];        [self.view makeToast:@"用户名不可用!"];
[_tableView reloadData];
}
       }andFailure:^{

        [self.view makeToast:@"用户名不可用!"];

 }];

}
    NSLog(@"停止编辑");
}
-(void)idendediting
{
NSString *idstring=[_personidField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([idstring isEqualToString:@""]|| idstring.length == 0|| idstring.length!=18) {
            [self.view makeToast:@"身份证号码不规范!"];
 _personidField.layer.borderColor=[[UIColor redColor]CGColor];

}else{
BOOL id= [httpTool validateIdentityCard:idstring];
if(id ==YES){
 _personidField.layer.borderColor=[[UIColor grayColor]CGColor];


}else{

_personidField.layer.borderColor = [[UIColor redColor] CGColor];
        [self.view makeToast:@"身份证号码不规范!"];

}
}
    NSLog(@"停止编辑");
}

-(void)phoneediting
{
NSString *phonestring=[_phoneField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([phonestring isEqualToString:@""]|| phonestring.length == 0|| phonestring.length!=11) {
  [self.view makeToast:@"手机号码不规范!"];
  _phoneField.layer.borderColor = [[UIColor redColor] CGColor];

}else{
BOOL id= [httpTool checkTelNumber:phonestring];
if(id ==YES){
_phonetype = @"yes";
 _phoneField.layer.borderColor=[[UIColor grayColor]CGColor];


}else{
        [self.view makeToast:@"手机号码不规范!"];

_phoneField.layer.borderColor = [[UIColor redColor] CGColor];
}
}
    NSLog(@"停止编辑");
}
-(void)youxiangendediting
{
NSString *yxstring=[_youxiangField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([yxstring isEqualToString:@""]|| yxstring.length == 0) {
            [self.view makeToast:@"邮箱不规范!"];

}else{
BOOL id= [httpTool isValidateEmail:yxstring];
if(id ==YES){
 _youxiangField.layer.borderColor=[[UIColor grayColor]CGColor];


}else{
            [self.view makeToast:@"邮箱不规范!"];

_youxiangField.layer.borderColor = [[UIColor redColor] CGColor];
}
}
    NSLog(@"停止编辑");
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}
#pragma mark UITableView dataScource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row ==0){
static NSString *cellid0 = @"cell0";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid0];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid0];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*用户名:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _yhmField = [[zhucetextfield alloc]init];
              _yhmField.delegate = self;
 _yhmField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
 _yhmField.placeholder = @"     请输入18位社会统一信用代码";
  [_yhmField addTarget:self action:@selector(endediting) forControlEvents:UIControlEventEditingDidEnd];// 可在自定义selector处
//             _yhmField.keyboardType = UIKeyboardTypeNumberPad;
_yhmField.keyboardType = UIKeyboardTypeASCIICapable;
             [cell.contentView addSubview:_yhmField];

     }
return cell;
}
if(indexPath.row ==1){
static NSString *cellid1 = @"cell1";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid1];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid1];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*密码:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _mmField = [[zhucetextfield alloc]init];
        [_mmField setSecureTextEntry:YES];
              _mmField.delegate = self;
                  _mmField.placeholder = @"     请输入密码";
_mmField.keyboardType = UIKeyboardTypeASCIICapable;

 _mmField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
             [cell.contentView addSubview:_mmField];
     }
return cell;
}
if(indexPath.row ==2){
static NSString *cellid2 = @"cell2";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid2];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid2];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*机构名称:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _jgnameField = [[zhucetextfield alloc]init];
              _jgnameField.delegate = self;
 _jgnameField.placeholder = @"     请输入机构名称";

 _jgnameField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
             [cell.contentView addSubview:_jgnameField];
     }
return cell;
}

if(indexPath.row ==3){
static NSString *cellid3 = @"cell3";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid3];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid3];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*机构性质:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
      _jgbutton = [UIButton buttonWithType:UIButtonTypeCustom];
      _jgbutton.frame =CGRectMake(label.right, label.top+5, KScreenWidth-20-label.width, 30);
          _jgbutton.backgroundColor = [UIColor whiteColor];

        [_jgbutton.layer setBorderColor:[UIColor blackColor].CGColor];
    [_jgbutton.layer setBorderWidth:1];
 [_jgbutton.layer setMasksToBounds:YES];
    [_jgbutton setTitle:@"选择机构性质" forState:UIControlStateNormal];
    _jgbutton.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_jgbutton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _jgbutton.layer.cornerRadius = _jgbutton.height/2;

        [_jgbutton addTarget:self action:@selector(jgaction) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_jgbutton];
     }
return cell;
}

if(indexPath.row ==4){
static NSString *cellid4 = @"cell4";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid4];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid4];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*组织机构代码证号:";
    label.numberOfLines = 0;
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _zznumField = [[zhucetextfield alloc]init];
              _zznumField.delegate = self;
 _zznumField.placeholder = @"     请输入组织机构代码证号";
_zznumField.keyboardType = UIKeyboardTypeASCIICapable;

 _zznumField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
             [cell.contentView addSubview:_zznumField];
     }
return cell;
}
if(indexPath.row ==5){
static NSString *cellid5 = @"cell5";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid5];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid5];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"税务登记证号:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _swnumField = [[zhucetextfield alloc]init];
              _swnumField.delegate = self;
 _swnumField.placeholder = @"     请输入税务登记证号";
_swnumField.keyboardType = UIKeyboardTypeASCIICapable;

 _swnumField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
             [cell.contentView addSubview:_swnumField];
     }
return cell;
}

if(indexPath.row ==6){
static NSString *cellid6 = @"cell6";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid6];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid6];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*注册地址:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  _huji1button = [UIButton buttonWithType:UIButtonTypeCustom];
      _huji1button.frame =CGRectMake(label.right, label.top+5, (KScreenWidth-20-label.width), 30);
          _huji1button.backgroundColor = [UIColor whiteColor];

        [_huji1button.layer setBorderColor:[UIColor blackColor].CGColor];
    [_huji1button.layer setBorderWidth:1];
 [_huji1button.layer setMasksToBounds:YES];
    [_huji1button setTitle:@"选择乡镇" forState:UIControlStateNormal];
    _huji1button.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_huji1button setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _huji1button.layer.cornerRadius = _huji1button.height/2;

        [_huji1button addTarget:self action:@selector(huji1action) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_huji1button];
         
                     _huji2button = [UIButton buttonWithType:UIButtonTypeCustom];
      _huji2button.frame =CGRectMake(label.right, _huji1button.bottom+10, (KScreenWidth-20-label.width), 30);
          _huji2button.backgroundColor = [UIColor whiteColor];

        [_huji2button.layer setBorderColor:[UIColor blackColor].CGColor];
    [_huji2button.layer setBorderWidth:1];
 [_huji2button.layer setMasksToBounds:YES];
    [_huji2button setTitle:@"选择村庄" forState:UIControlStateNormal];
    _huji2button.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_huji2button setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _huji2button.layer.cornerRadius = _huji1button.height/2;

        [_huji2button addTarget:self action:@selector(huji2action) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_huji2button];
         

     }
return cell;
}
if(indexPath.row ==7){
static NSString *cellid7 = @"cell7";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid7];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid7];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*详细地址:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _xiangxiField = [[zhucetextfield alloc]init];
              _xiangxiField.delegate = self;
         
 _xiangxiField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
//            _personidField.keyboardType = UIKeyboardTypeNumberPad;
_xiangxiField.placeholder = @"     请输入详细地址";
             [cell.contentView addSubview:_xiangxiField];
     }
return cell;
}

if(indexPath.row ==8){
static NSString *cellid8 = @"cell8";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid8];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid8];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*法人代表:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _xmField = [[zhucetextfield alloc]init];
              _xmField.delegate = self;
 _xmField.placeholder = @"     请输入法人代表姓名";

 _xmField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
             [cell.contentView addSubview:_xmField];
     }
return cell;
}
if(indexPath.row ==9){
static NSString *cellid9 = @"cell9";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid9];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid9];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*身份证号码:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _personidField = [[zhucetextfield alloc]init];
              _personidField.delegate = self;
 _personidField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
  _personidField.placeholder = @"     请输入身份证号码";
  [_personidField addTarget:self action:@selector(idendediting) forControlEvents:UIControlEventEditingDidEnd];// 可在自定义selector处

            _personidField.keyboardType = UIKeyboardTypeASCIICapable;

             [cell.contentView addSubview:_personidField];
     }
return cell;



}

if(indexPath.row ==10){
static NSString *cellid10 = @"cell10";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid10];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid10];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*联系电话:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _lxphoneField = [[zhucetextfield alloc]init];
              _lxphoneField.delegate = self;
 _lxphoneField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
  _lxphoneField.placeholder = @"     请输入联系电话";


            _lxphoneField.keyboardType = UIKeyboardTypeASCIICapable;

             [cell.contentView addSubview:_lxphoneField];
     }
return cell;



}

if(indexPath.row ==11){
static NSString *cellid11 = @"cell11";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid11];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid11];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*手机号码:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _phoneField = [[zhucetextfield alloc]init];
              _phoneField.delegate = self;
 _phoneField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
  _phoneField.placeholder = @"     请输入手机号码";
  [_phoneField addTarget:self action:@selector(phoneediting) forControlEvents:UIControlEventEditingDidEnd];// 可在自定义selector处

            _phoneField.keyboardType = UIKeyboardTypeNumberPad;

             [cell.contentView addSubview:_phoneField];
     }
return cell;



}
if(indexPath.row ==12){
static NSString *cellid12 = @"cell12";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid12];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid12];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @" QQ号码:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _qqField = [[zhucetextfield alloc]init];
              _qqField.delegate = self;
 _qqField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
                 _qqField.placeholder = @"     请输入QQ号码";

            _qqField.keyboardType = UIKeyboardTypeNumberPad;

             [cell.contentView addSubview:_qqField];
     }
return cell;
}

if(indexPath.row ==13){
static NSString *cellid13 = @"cell13";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid13];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid13];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*电子邮箱:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _youxiangField = [[zhucetextfield alloc]init];
              _youxiangField.delegate = self;
                _youxiangField.placeholder = @"     请输入电子邮箱";
 _youxiangField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width, 30);
 _youxiangField.keyboardType = UIKeyboardTypeASCIICapable;
 [_youxiangField addTarget:self action:@selector(youxiangendediting) forControlEvents:UIControlEventEditingDidEnd];// 可在自定义selector处
//            _personidField.keyboardType = UIKeyboardTypeNumberPad;

             [cell.contentView addSubview:_youxiangField];
     }
return cell;
}

if(indexPath.row ==14){
static NSString *cellid14 = @"cell14";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid14];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid14];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*所属行业:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
            _hangyebutton = [UIButton buttonWithType:UIButtonTypeCustom];
      _hangyebutton.frame =CGRectMake(label.right, label.top+5, KScreenWidth-20-label.width, 30);
          _hangyebutton.backgroundColor = [UIColor whiteColor];

        [_hangyebutton.layer setBorderColor:[UIColor blackColor].CGColor];
    [_hangyebutton.layer setBorderWidth:1];
 [_hangyebutton.layer setMasksToBounds:YES];
    [_hangyebutton setTitle:@"选择行业类型" forState:UIControlStateNormal];
    _hangyebutton.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_hangyebutton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _hangyebutton.layer.cornerRadius = _hangyebutton.height/2;

        [_hangyebutton addTarget:self action:@selector(hyaction) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_hangyebutton];
         
                      _hangye2button = [UIButton buttonWithType:UIButtonTypeCustom];
      _hangye2button.frame =CGRectMake(label.right, label.bottom, KScreenWidth-20-label.width, 30);
          _hangye2button.backgroundColor = [UIColor whiteColor];

        [_hangye2button.layer setBorderColor:[UIColor blackColor].CGColor];
    [_hangye2button.layer setBorderWidth:1];
 [_hangye2button.layer setMasksToBounds:YES];
    [_hangye2button setTitle:@"选择行业" forState:UIControlStateNormal];
    _hangye2button.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_hangye2button setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _hangye2button.layer.cornerRadius = _hangyebutton.height/2;

        [_hangye2button addTarget:self action:@selector(hy2action) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_hangye2button];
       
         
         
     }
return cell;
}
if(indexPath.row ==15){
static NSString *cellid15 = @"cell15";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid15];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid15];
  UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
  
    label.text = @"*手机验证码:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
        _yanzField = [[zhucetextfield alloc]init];
              _yanzField.delegate = self;
 _yanzField.frame = CGRectMake(label.right, label.top+5, (KScreenWidth-20)-label.width-80, 30);
  _yanzField.placeholder = @"     请输入验证码";

            _yanzField.keyboardType = UIKeyboardTypeNumberPad;

             [cell.contentView addSubview:_yanzField];
          _yanzbutton = [myView creatButtonWithFrame:CGRectMake(_yanzField.right+10, label.top+5,80, 30) title:@"获取验证码" tag:1000 tintColor:[UIColor whiteColor] backgroundColor:[UIColor colorWithRed:18/255.0  green:129/255.0  blue:201/255.0 alpha:1]];
        _yanzbutton.layer.cornerRadius = 10;
        _yanzbutton.font = [UIFont systemFontOfSize:14];
        [_yanzbutton addTarget:self action:@selector(getVerificationCode) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:_yanzbutton];
              }
return cell;
}

else{
static NSString *cellid12 = @"cell12";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid12];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid12];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
      button.frame = CGRectMake((KScreenWidth-200)/2, 10, 200, 40);
          button.backgroundColor = [UIColor blueColor];

        [button.layer setBorderColor:[UIColor blueColor].CGColor];
    [button.layer setBorderWidth:1];
 [button.layer setMasksToBounds:YES];
    [button setTitle:@"同意以上条款,立即注册" forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [button setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
        button.layer.cornerRadius = button.height/2;
                [button addTarget:self action:@selector(action) forControlEvents:UIControlEventTouchUpInside];

            [cell.contentView addSubview:button];
     }
return cell;
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  17;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 6||indexPath.row == 14){
return 80;
}else{
return 40;
}


}
- (void)action{
NSString *yhmtring=[_yhmField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

NSString *jgnametring=[_jgnameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];


NSString *zznumtring=[_zznumField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

NSString *swnumtring=[_swnumField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];


NSString *lxphonetring=[_lxphoneField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

NSString *phonetring=[_phoneField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

NSString *mimatring=[_mmField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *nametring=[_xmField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *idtring=[_personidField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *youxiangstring=[_youxiangField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *qqstring=[_qqField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *xxstring=[_xiangxiField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *yzstring=[_yanzField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if([mimatring isEqualToString:@""]|| mimatring.length == 0){
        [self.view makeToast:@"对不起，密码为空"];
}else if (![_nametype isEqualToString:@"yes"]){
        [self.view makeToast:@"对不起，用户名不规范"];
}else if ([jgnametring isEqualToString:@""]|| jgnametring.length == 0){
        [self.view makeToast:@"对不起，机构名称为空"];
}else if(![_jgselarray isKindOfClass:[NSArray class]] && _jgselarray.count == 0){
        [self.view makeToast:@"对不起，机构性质为空"];
}else if ([zznumtring isEqualToString:@""]|| zznumtring.length == 0){
        [self.view makeToast:@"对不起，组织机构代码证号为空"];
}else if(![_huji1selarray isKindOfClass:[NSArray class]] && _huji1selarray.count == 0){
        [self.view makeToast:@"对不起，乡镇为空"];

}else if(![_huji2selarray isKindOfClass:[NSArray class]] && _huji1selarray.count == 0){
        [self.view makeToast:@"对不起，村庄为空"];

}else if ([xxstring isEqualToString:@""]|| xxstring.length == 0){
        [self.view makeToast:@"对不起，详细地址为空"];
}else if ([nametring isEqualToString:@""]|| nametring.length == 0){
        [self.view makeToast:@"对不起，法人代表姓名为空"];
}else if ([idtring isEqualToString:@""]|| idtring.length == 0){
        [self.view makeToast:@"对不起，身份证为空"];
}else if (![httpTool validateIdentityCard:idtring]){
        [self.view makeToast:@"对不起，身份证不规范"];
}else if ([lxphonetring isEqualToString:@""]|| lxphonetring.length == 0){
        [self.view makeToast:@"对不起，联系电话为空"];
}else if ([phonetring isEqualToString:@""]|| phonetring.length == 0){
        [self.view makeToast:@"对不起，手机号码为空"];
}else if (![httpTool checkTelNumber:phonetring]){
        [self.view makeToast:@"对不起，手机号码不规范"];
}
else if ([youxiangstring isEqualToString:@""]|| youxiangstring.length == 0){
        [self.view makeToast:@"对不起，电子邮箱为空"];
}else if (![httpTool isValidateEmail:youxiangstring]){
        [self.view makeToast:@"对不起，邮箱不规范"];
}else if ([yzstring isEqualToString:@""]|| yzstring.length == 0){
        [self.view makeToast:@"对不起，验证码为空"];
}else if(![_hyselarray isKindOfClass:[NSArray class]] && _hyselarray.count == 0){
        [self.view makeToast:@"对不起，行业类别为空"];

}else if(![_hy2selarray isKindOfClass:[NSArray class]] && _hy2selarray.count == 0){
        [self.view makeToast:@"对不起，行业为空"];

}else{
NSString *url = [NSString stringWithFormat:@"%@",kqiye];
NSMutableArray *upjigouarray = [NSMutableArray array];//机构
for (NSString *string in _jgselarray) {

 for (NSDictionary *dic in _jgarray) {
    if ([string isEqualToString:dic[@"name"]]) {
[upjigouarray addObject: dic[@"id"]];
    }
    }
    }
    NSString *upjistring = [upjigouarray componentsJoinedByString:@","];
url = [NSString stringWithFormat:@"%@&accounts.c_type=%@",url,upjistring];//机构


NSString *uphujistring = [NSString string];
NSString *hujistring = [_huji2selarray componentsJoinedByString:@","];
 for (NSDictionary *dic in _city2array) {
    if ([hujistring isEqualToString:dic[@"name"]]) {
uphujistring = dic[@"code"];
    }
    }
url = [NSString stringWithFormat:@"%@&accounts.d_address=%@",url,uphujistring];//注册地址


NSMutableArray *uphangyeyarray = [NSMutableArray array];
for (NSString *string in _hyselarray) {

 for (NSDictionary *dic in _hyarray) {
    if ([string isEqualToString:dic[@"name"]]) {
[uphangyeyarray addObject: dic[@"id"]];
    }
    }
    }
    
 for (NSString *string in _hy2selarray) {

 for (NSDictionary *dic in _hy2array) {
    if ([string isEqualToString:dic[@"name"]]) {
[uphangyeyarray addObject: dic[@"id"]];
    }
    }
    }
      NSString *hangyestring = [uphangyeyarray componentsJoinedByString:@","];

url = [NSString stringWithFormat:@"%@&accounts.industry=%@",url,hangyestring];//行业

url = [NSString stringWithFormat:@"%@&accounts.regnum=%@",url,_yhmField.text];//密码
NSString *newpassword = [ self md5:mimatring];
url = [NSString stringWithFormat:@"%@&accounts.password=%@",url,newpassword];//用户名
if (jgnametring.length>0){
    NSString *jgnameStr=[self URLEncodedString:jgnametring];
url = [NSString stringWithFormat:@"%@&accounts.cname=%@",url,jgnameStr];//机构名称
}
url = [NSString stringWithFormat:@"%@&accounts.orcode=%@",url,zznumtring];//组织机构代码证号
url = [NSString stringWithFormat:@"%@&accounts.taxcode=%@",url,_swnumField.text];//税务登记证号
if (xxstring.length>0){
    NSString *xxStr=[self URLEncodedString:xxstring];
url = [NSString stringWithFormat:@"%@&accounts.r_address=%@",url,xxStr];//详细地址
}
if (nametring.length>0){
    NSString *nameStr=[self URLEncodedString:nametring];
url = [NSString stringWithFormat:@"%@&accounts.realname=%@",url,nameStr];
}
url = [NSString stringWithFormat:@"%@&accounts.id_card=%@",url,_personidField.text];//身份证号

url = [NSString stringWithFormat:@"%@&accounts.phone=%@",url,_lxphoneField.text];//联系电话
url = [NSString stringWithFormat:@"%@&accounts.m_phone=%@",url,_phoneField.text];//电话
if(qqstring.length>0){
url = [NSString stringWithFormat:@"%@&accounts.qq=%@",url,qqstring];//qq
}
url = [NSString stringWithFormat:@"%@&accounts.email=%@",url,_youxiangField.text];//电子邮箱
url = [NSString stringWithFormat:@"%@&codeId=%@",url,_codeId];//验证码coldid
url = [NSString stringWithFormat:@"%@&code=%@",url,_yanzField.text];//验证码
[httpTool ZBPostNetDataWith:url withDic:nil andSuccess:^(NSDictionary* dictionary){

       if ([[NSString stringWithFormat:@"%@",dictionary[@"success"]]isEqualToString:@"true"]) {
           [self .view makeToast:dictionary[@"msg"]];
                           [NSThread sleepForTimeInterval:1.0];

              UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
          DanLi *danli = [[DanLi alloc] init];
    danli.stay = @"no";
 OALoginViewController * loginVC =  [storyBoard instantiateViewControllerWithIdentifier:@"LoginVC"];
     [[NSUserDefaults standardUserDefaults] setObject:@"N" forKey:@"autoLogin"];
    self.view.window.rootViewController = loginVC;
           
     
}else{
NSString *string = dictionary[@"msg"];
           [self .view makeToast:string ];

}
       }andFailure:^{

        [self.view makeToast:@"网络连接失败!"];

 }];


}
}
- (NSString *)md5:(NSString *)str
{
    const char *cStr = [str UTF8String];
    unsigned char result[16];
    CC_MD5(cStr, (CC_LONG)strlen(cStr), result); // This is the md5 call
    return [NSString stringWithFormat:
            @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
            result[0], result[1], result[2], result[3],
            result[4], result[5], result[6], result[7],
            result[8], result[9], result[10], result[11],
            result[12], result[13], result[14], result[15]
            ];
}
-(NSString *)URLEncodedString:(NSString *)str
{
    NSString *encodedString = (NSString *)
    CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                              (CFStringRef)str,
                                                              NULL,
                                                              (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                              kCFStringEncodingUTF8));
    
    return encodedString;
}
- (void)getVerificationCode
{


if (![_phonetype isEqualToString:@"yes"]) {
   [self.view makeToast:@"请重新输入手机号码!"];
}else{
    _label = [[UILabel alloc]initWithFrame:self.yanzbutton.bounds];
    
    _timer = [[NSTimer alloc]init];
    _timer= [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(countDown) userInfo:nil repeats:YES];
    [_timer setFireDate:[NSDate distantPast]];
    //请求服务器发送短信验证码
     NSString *url = [NSString stringWithFormat:@"%@%@",kqiyeyanz,_phoneField.text];
       [httpTool ZBPostNetDataWith:url withDic:nil andSuccess:^(NSDictionary* dictionary){
       if ([[NSString stringWithFormat:@"%@",dictionary[@"success"]]isEqualToString:@"true"]) {
           [self .view makeToast:dictionary[@"msg"]];
           _codeId = dictionary[@"codeId"];
}else{

           [self .view makeToast:dictionary[@"msg"]];

}
       }andFailure:^{

        [self.view makeToast:@"网络连接失败!"];

 }];
   }
    //......
}
- (void)countDown
{
    countDownTime--;
    if (countDownTime<=0||countDownTime ==180) {
        _label.hidden = YES;
        _yanzbutton.hidden = NO;
        _yanzbutton.userInteractionEnabled = YES;
        [_timer setFireDate:[NSDate distantFuture]];
        countDownTime =180;
    }else{
        _label.hidden = NO;
        _label.text = [NSString stringWithFormat:@"(%ds)重新获取",countDownTime];
        _label.font = [UIFont systemFontOfSize:12];
        _label.backgroundColor = [UIColor colorWithRed:18/255.0  green:129/255.0  blue:201/255.0 alpha:1];
        _label.layer.cornerRadius = 8;
        _label.clipsToBounds = YES;
        _label.textAlignment = NSTextAlignmentCenter;
        _label.textColor= [UIColor whiteColor];
        [_yanzbutton addSubview:_label];
        _yanzbutton.userInteractionEnabled = NO;
    }
}
- (void)jgaction{
[self.view endEditing:YES];
    [EYTagPopupView popViewWithTitle:@"选择机构性质"
                                tags:_jgNSarray
                                 selectTags:_jgselarray
                                type:EYTagPopupView_Type_Single_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                           if(tags.count==0){
                                                    _jgselarray = tags;
                             [_jgbutton setTitle:@"选择机构性质" forState:UIControlStateNormal];

                           
                           }else{
                         _jgselarray = tags;
                        
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_jgselarray componentsJoinedByString:@","];
                             [_jgbutton setTitle:string forState:UIControlStateNormal];
                             
                             }
                         } dismissBlock:^{
                         }];

}
- (void)huji1action{
{[self.view endEditing:YES];
    [EYTagPopupView popViewWithTitle:@"选择村庄"
                                tags:_huji1array
                                 selectTags:_huji1selarray
                                type:EYTagPopupView_Type_Single_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                           if(tags.count==0){
                                                 _huji1selarray = tags;

                                              [_huji1button setTitle:@"选择村庄" forState:UIControlStateNormal];

                           
                           }else{
                         _huji1selarray = tags;
                        
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_huji1selarray componentsJoinedByString:@","];
                             [_huji1button setTitle:string forState:UIControlStateNormal];
                              NSString *id = [NSString string];
                      for (NSDictionary *dic in _cityarray) {
    if ([string isEqualToString:dic[@"name"]]) {
id = dic[@"code"];

    }
    }
    NSString *url = [NSString stringWithFormat:@"%@%@",kpersoncity2,id];
           [httpTool ZBPostNetDataWith:url withDic:nil andSuccess:^(NSDictionary* dictionary){
    
    _city2array = dictionary[@"districtList"];
    NSMutableArray *array2 = [NSMutableArray array];
    for (NSDictionary *dic in _city2array) {
    [array2 addObject: dic[@"name"]];
}
    _huji2array = array2;
    [_tableView reloadData];
       }andFailure:^{

        [self.view makeToast:@"网络错误!"];

 }];
                             
                             }
                         } dismissBlock:^{
                         }];
}

}
- (void)huji2action{
[self.view endEditing:YES];
if(_huji1selarray.count >0){
    [EYTagPopupView popViewWithTitle:@"选择乡镇"
                                tags:_huji2array
                                 selectTags:_huji2selarray
                                type:EYTagPopupView_Type_Single_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                           if(tags.count==0){
                                                 _huji2selarray = tags;

                             [_huji2button setTitle:@"选择乡镇" forState:UIControlStateNormal];

                           }else{
                         _huji2selarray = tags;
                        
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_huji2selarray componentsJoinedByString:@","];
                             [_huji2button setTitle:string forState:UIControlStateNormal];
                     
                            
                             }
                         } dismissBlock:^{
                         }];
                         }else{
                         
                         [self.view makeToast:@"请选择乡镇"];
                         }


}


- (void)hyaction{
{[self.view endEditing:YES];
    [EYTagPopupView popViewWithTitle:@"选择行业类型"
                                tags:_hyNSarray
                                 selectTags:_hyselarray
                                type:EYTagPopupView_Type_Single_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                           if(tags.count==0){
                                      _hyselarray = tags;
                             [_hangyebutton setTitle:@"选择行业类型" forState:UIControlStateNormal];

                           
                           
                           }else{
                         _hyselarray = tags;
                        
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_hyselarray componentsJoinedByString:@","];
                             [_hangyebutton setTitle:string forState:UIControlStateNormal];
                              NSString *id = [NSString string];
                      for (NSDictionary *dic in _hyarray) {
    if ([string isEqualToString:dic[@"name"]]) {
id = dic[@"id"];

    }
    }
    NSString *url = [NSString stringWithFormat:@"%@%@",kqiyehangye2,id];
           [httpTool ZBPostNetDataWith:url withDic:nil andSuccess:^(NSDictionary* dictionary){
    
    _hy2array = dictionary[@"professionsChildList"];
    NSMutableArray *array2 = [NSMutableArray array];
    for (NSDictionary *dic in _hy2array) {
    [array2 addObject: dic[@"name"]];
}
    _hy2NSarray = array2;
    [_tableView reloadData];
       }andFailure:^{

        [self.view makeToast:@"网络错误!"];

 }];
                             
                             }
                         } dismissBlock:^{
                         }];
}

}
- (void)hy2action{
[self.view endEditing:YES];
if(_hyselarray.count >0){
    [EYTagPopupView popViewWithTitle:@"选择行业"
                                tags:_hy2NSarray
                                 selectTags:_hy2selarray
                                type:EYTagPopupView_Type_Single_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                           if(tags.count==0){
                                             _hy2selarray = tags;
                             [_hangye2button setTitle:@"选择行业" forState:UIControlStateNormal];

                           
                           }else{
                         _hy2selarray = tags;
                        
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_hy2selarray componentsJoinedByString:@","];
                             [_hangye2button setTitle:string forState:UIControlStateNormal];
                     
                            
                             }
                         } dismissBlock:^{
                         }];
                         }else{
                         
                         [self.view makeToast:@"请选择行业类型"];
                         }


}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
